package com.scqkxx.gamebox.activity.register;

import android.content.ContentValues;
import android.text.TextUtils;
import android.view.View;

import com.jyn.vcview.VerificationCodeView;
import com.scqkxx.gamebox.R;
import com.scqkxx.gamebox.activity.activities.utils.ActivityUtil;
import com.scqkxx.gamebox.activity.activities.view.TitleView;
import com.scqkxx.gamebox.activity.myself.ModifyPasswordActivity;
import com.scqkxx.gamebox.databinding.ActivityMailCodeBinding;
import com.scqkxx.gamebox.databinding.ActivityRegisterCodeBinding;
import com.scqkzqtz.base.base.BaseActivity;
import com.scqkzqtz.base.library.utils.PreferenceUtils;

public class RegisterCheckCodeActivity extends BaseActivity<ActivityRegisterCodeBinding> {

    protected  String code  = "";
    String mEmailUrl = "";

    @Override
    public int setLayoutId() {
        return R.layout.activity_register_code;
    }

    @Override
    public void init() {
        mEmailUrl = getIntent().getStringExtra("EmailUrl");
        binding.mTitleView.setTitleName("注册");
        binding.eailUrl.setText("我们向"+mEmailUrl+"发送了           一个验证码,请在下方输入");
        binding.mTitleView.setOnTitleClickListener((int titleType) -> finish());

        binding.verificayionView.setOnCodeFinishListener(new VerificationCodeView.OnCodeFinishListener() {
            @Override
            public void onTextChange(View view, String content) {

            }

            @Override
            public void onComplete(View view, String content) {
                code  = content;
            }
        });

        binding.tvConfirm.setOnClickListener(v -> {
            if (!TextUtils.isEmpty(code) && code.length() >= 4 ){
                PreferenceUtils.commitString("checkCode",code);
                ContentValues contentValues = new ContentValues();
                contentValues.put("code"  , code);
                ActivityUtil.switchTo(RegisterCheckCodeActivity.this,RegisterPasswordActivity.class,contentValues);
            }
        });
    }
}
